//
//  LFMemberViewController.m
//  LoveFruit
//
//  Created by 马海江 on 16/9/26.
//  Copyright © 2016年 张令林. All rights reserved.
//

#import "LFMemberViewController.h"
#import "LFLFMemberTacticViewCell.h"

static NSString *cellID = @"cellID";
@interface LFMemberViewController ()<UITableViewDelegate, UITableViewDataSource>{
    NSMutableDictionary *dict;
}
@end

@implementation LFMemberViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    dict = [NSMutableDictionary dictionary];
    self.navigationItem.title = @"会员中心";
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem barBuutonItemWithTarget:self action:@selector(backItem) icon:@"btn_backItem" highlighticon:nil];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupUI];
}

- (void)setupUI{
    UIImageView *headView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"member"]];
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(@64);
        make.height.equalTo(@252);
    }];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerNib:[UINib nibWithNibName:@"LFLFMemberTacticViewCell" bundle:nil] forCellReuseIdentifier:cellID];
    // 取消系统分割线
    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(headView.mas_bottom);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        LFLFMemberTacticViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.imageview.image = [UIImage imageNamed:@"chengzhangzhi"];
        cell.detailButton.hidden = YES;
        cell.label.text = @"成长值";
        cell.detailLabel.text = @"会员等级有效期为1年，1年后扣减相应等级成长值，剩余的成长值重新计算会员级别。";
        return cell;
    }else if (indexPath.row == 1){
        LFLFMemberTacticViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.imageview.image = [UIImage imageNamed:@"chengzhanggonglue"];
        cell.label.text = @"成长攻略";
        cell.detailLabel.text = @"会员等级越高获得的积分越多。\n1、注册会员：0.5倍积分\n2、普通会员：1倍积分\n3、白银会员：1.5倍积分\n4、黄金会员：2倍积分\n5、钻石会员：3倍积分";
        return cell;
    }else if (indexPath.row == 2){
        LFLFMemberTacticViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.imageview.image = [UIImage imageNamed:@"tequan"];
        cell.label.text = @"特权";
        cell.detailLabel.text = @"1、注册会员：30>成长值>=0；\n2、普通会员：199>成长值>=30；\n1、白银会员：499>成长值>=199；\n1、黄金会员：999>成长值>=499；\n1、钻石会员：成长值>=999;";
        return cell;
    }else{
        LFLFMemberTacticViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.imageview.image = [UIImage imageNamed:@"huiyuandengjishuoming"];
        cell.label.text = @"会员等级说明";
        cell.detailLabel.text = @"1、购买精选商品实付金额1：1转化为成长值（不包含优惠券等抵扣部分）；\n2、在“天津、西安、成都、南京、佛山”下单，完成订单后可以获得10成长值；\n3、商品退换货，需扣除该商品所获得的成长值；\n4、订单取消，需扣除该订单所获得的成长值；\n5、因作弊等行为产生的成长值，爱鲜蜂有权扣除相应的成长值；";
        return cell;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 82;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}
- (void)backItem{
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
